package com.airlines.crewassignment.service.linkline.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.airlines.base.config.datasource.PrimaryDataSourceConfig;
import com.airlines.base.service.base.impl.BaseServiceImpl;
import com.airlines.crewassignment.dao.linkline.LinkLineFMapper;
import com.airlines.crewassignment.domain.LinkLine;
import com.airlines.crewassignment.service.linkline.LinkLineFService;

/**
 * @author xxxx
 * @date 2018年6月19日 
 * @description
 */
@Service
public class LinkLineFServiceImpl extends BaseServiceImpl<LinkLine, Integer> implements LinkLineFService{
	@Autowired
	private LinkLineFMapper linkLineFMapper;

	@Autowired
	@Override
	public void setBaseMapper() {
		super.setBaseMapper(linkLineFMapper);
	}
	
	/**
	 * 同时删除T3001数据
	 */
	@Transactional(transactionManager=PrimaryDataSourceConfig.TRANSACTION_MANAGER)
	@Override
	public int deleteByPrimaryKey(Integer id) {
		LinkLine l  = linkLineFMapper.selectByPrimaryKey(id);
		linkLineFMapper.deleteByPrimaryKeyT3001(l.getFlightDate(), l.getCrewLinkLineNo());
		return linkLineFMapper.deleteByPrimaryKey(id);
	}
	/**
	 * 同时新增T3001数据
	 */
	@Transactional(transactionManager=PrimaryDataSourceConfig.TRANSACTION_MANAGER)
	@Override
	public int saveSelective(LinkLine l) {
		linkLineFMapper.insertSelectiveT3001(l);
		return linkLineFMapper.insertSelective(l);
	}
	@Transactional(transactionManager=PrimaryDataSourceConfig.TRANSACTION_MANAGER)
	@Override
	public int updateByPrimaryKeySelective(LinkLine l) {
		linkLineFMapper.updateByPrimaryKeySelectiveT3001(l);
		return linkLineFMapper.updateByPrimaryKeySelective(l);
	}
}
